﻿using Auxiliary.VecMath;
using Simple3DRedactor.Domain;
using Tao.OpenGl;

namespace Simple3DRedactor.OpenGLViewer
{
    class SphereView : GeometryView<Sphere>
    {
        private readonly Glu.GLUquadric _quadric = Glu.gluNewQuadric();
        
        public SphereView(Sphere obj, ObjectViewFactory factory)
            : base(obj, factory)
        {
            Glu.gluQuadricTexture(_quadric, Gl.GL_TRUE);
        }

        protected override void RenderImpl()
        {
            Glu.gluSphere(_quadric, InnerObject.Radius, InnerObject.Slices, InnerObject.Stacks);
        }

        protected override Vector3D MaxPoint
        {
            get { return new Vector3D(InnerObject.Radius, InnerObject.Radius, InnerObject.Radius); }
        }

        protected override Vector3D MinPoint
        {
            get { return new Vector3D(-InnerObject.Radius, -InnerObject.Radius, -InnerObject.Radius); }
        }
    }
}
